<template>
  <div class="record">
    <TopView name="record" title="流年记" msg="时间像鱼飞速滑过留下激情，却不留痕迹"></TopView>

    <div class="course" v-if="activities.length > 0">
      <div class="time-line" v-for="(activity, index) in activities" :key="index">
        <div class="item-border" :style="index + 1 === activities.length ? 'border-left:0;border-right:0' : ''">
          <div class="time-div">
            <span class="time-span"><i class="el-icon-check"></i></span>
          </div>
          <div class="line-item">
            <div class="time-con">
              <p class="title">{{ activity.nickname + ' ✍️ ' + activity.createTime }}</p>
              <p class="doc">{{ activity.content }}</p>
              <el-image v-if="activity.picUrl" :src="activity.picUrl" lazy fit="cover" />
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import TopView from '@/components/TopView.vue'
import recordApi from '@/api/record'
export default {
  name: 'RecordView',
  components: {
    TopView
  },
  data() {
    return {
      activities: []
    }
  },
  created() {
    this.getList()
  },
  methods: {
    getList() {
      recordApi.list().then(response => {
        if (response.code === 20000) {
          this.activities = response.data.data // 用于查询
        } else {
          this.$message.error(response.message)
        }
      })
    }
  }
}
</script>

<style lang="less" scoped>
.course {
  width: 100%;
  padding: 150px 15% 50px 15%;
  box-sizing: border-box;
  opacity: 0.9;

  .time-line {
    width: 100%;
    margin: auto;
    height: 230px;
    position: relative;

    &:nth-child(odd) {
      .item-border {
        position: absolute;
        left: 1.5px;
        border-top: 3px solid #ffffff;
        border-right: 3px solid #ffffff;
        box-sizing: border-box;

        .time-div {
          position: absolute;
          right: -15px;
          top: -15px;
        }

        .line-item {
          .time-con {
            text-align: left;
            .title {
              right: 0;
            }
          }
        }
      }
    }
    &:nth-child(even) {
      .item-border {
        position: absolute;
        right: 1.5px;
        border-top: 3px solid #ffffff;
        border-left: 3px solid #ffffff;
        box-sizing: border-box;

        .time-div {
          position: absolute;
          left: -15px;
          top: -15px;
        }

        .line-item {
          position: absolute;
          right: 0;

          .time-con {
            text-align: left;
            .title {
              left: 0;
            }
          }
        }
      }
    }
    .item-border {
      width: 50%;
      height: 100%;

      .time-div {
        width: 30px;
        height: 30px;

        .time-span {
          display: inline-block;
          width: 100%;
          height: 100%;
          border-radius: 50%;
          color: #ffffff;
          text-align: center;
          line-height: 30px;
          margin: auto;
          background: #0bbd87;
          font-size: 20px;
        }
      }

      .line-item {
        width: 80%;
        height: auto;
        background: #0bbd87;
        position: absolute;
        top: -65px;
        padding: 20px;
        border-radius: 10px;

        .time-con {
          .title {
            position: absolute;
            top: -30px;
            font-size: 18px;
            color: #fff;
            font-weight: bold;
          }
          .doc {
            font-size: 15px;
            color: #fff;
            margin-bottom: 15px;
          }
          .el-image {
            width: 100%;
            height: 190px;
            vertical-align: middle;
          }
        }
      }
    }
  }
}
</style>
